<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>闭包内存泄露</title>
	<style type="text/css">
</style>
</head>
<body>
	<div class="container">
		<h1>闭包内存泄露</h1>
		<div desc="houdunren">在线学习</div>
		<div desc="hdcms">开源产品</div>
	</div>
	<body>
	</body>

	<script src="https://cdn.staticfile.org/jquery/3.2.0/jquery.js"></script>
	<script>
		let divs = document.querySelectorAll("div");
		divs.forEach(function(item) {
			var desc = item.getAttribute("desc")
			item.addEventListener("click", function() {
				console.log(desc);
			});
			// 通过清除不需要的数据解决内存泄漏问题
			item = null ;
		});


		
	</script>
</body>
</html>